<?php
if(!defined('BZ_XTBLOG') || !defined('BZ_WJSCUZ')) {
	exit('Access Denied');
}
$fid =verify_id($_GET['fid']);
$act =$_GET['act'];
$forum=$db->get_one('forum_class'," `id` ='$fid'",'');
$wzxx_title =$forum['name'].'-发表帖子-'.$wzxx_title.'';
$wzxx_gj    =$forum['value'].'-发表帖子-'.$wzxx_gj.'';
$wzxx_ms    =$forum['value'].'-发表帖子-'.$wzxx_ms.'';
     $ltid  =$forum['id'];
     $ltname=$forum['name'];
$mmyz=$_POST['mmyz'];
$name=$_POST['name'];
$content=$_POST['content'];
$maa =$_POST['maa'];
$mbb =$_POST['mbb'];
$flid=$_POST['flid'];
$lx  =$_POST['lx'];
$fjck=$_POST['fjck'];
$fjjb=$_POST['fjjb'];
$forumsjpd=$db->get_one('forum'," `uid` ='$user_uid' ORDER BY `id` DESC LIMIT 0, 1",'');
$tiaosu=$db->num_rows('forum'," `uid` ='$user_uid' AND `time_b` > '$time_jt' ",'id');
if(($time - $forumsjpd[time_b]) < Bingz_config('forum_config_ftjg')){
	  $ftsjpd='1';
}

 
        foreach($_POST['tepao'] as $a => $val ){
                echo  $a.$val;
        }




if(!$user_uid){
		$pdid='2';
	}else if(!$forum){
		$pdid='1';
  }elseif(empty($name) or empty($content)){
  	$pdid='3';
		$mmts='你好，不能为空！';
  }elseif(mb_strlen($name,'utf-8') < 2 or mb_strlen($content,'utf-8') < 2 ){
  	$pdid='3';
		$mmts='你好，内容字符不能小于 2 ！';
	}else if($tiaosu >= $user_class->user_teoo($user_uid,'sezi_forum_fat')){
  	$pdid='3';
		$mmts='你好，你所在用户组限制发帖条数！';
	}else if($db->get_one('forum'," `cid` ='$fid' AND `uid` ='$user_uid' AND `name` = '$name' AND `time_b` > '$time_jt'",'')){
  	$pdid='3';
		$mmts='你好，禁止重复提交！';
  }elseif($ftsjpd){
  	$pdid='3';
		$mmts='你好，发帖过快！请稍后提交！';
	}else if($act == 'm'){
       if($id=Bingz_forum_post($fid,$user_uid,$name,$content,'','',$_POST['type_lx'],$_POST['sz_tz'],$_POST['sz_lm'])){
             $pdid='4';
     if(preg_match_all("/@(.*?)(?:[,| ])/",$content,$smsoon)){
        $smsoon[1]=array_unique($smsoon[1]);
        foreach( $smsoon[1] as $a=> $val){
                if($nnmm=$db->get_one('user'," `name` = '$val' ",'uid')){
                	 	  $db->insert('message',array('id' => 'NULL', 'fo_id' => 0, 'to_id' => $nnmm[uid], 'content' => "帖子《[url=index.php?$Bingz_ml=forum&$Bingz_md=viewthread&fid=$forum[id][bzsid]]$forum[name][/url]》@我了！", 'time_a'=> $time ));
                }
        }
     }
     if($_POST['type_tpts'] > '0'){$_POST['type_tpts']=strtotime(date("Y-m-d 00:00:00",strtotime(" +".$_POST['type_tpts']." day")));;}
     foreach($_POST['tepao'] as $a => $val ){
     	    if($val){
     	       $db->insert('forum_polloption',array('id' => 'NULL','tid' => $id,'uid' => $user_uid, 'votes' => '0', 'name'=> $val));	
     	       $db->update('forum',array('type' => '1' ,'type_tp_sj' => $_POST['type_tpts'] ),"`id` ='$id'");
     	    }
     }
    	 }else{
		         $pdid='5';
       }
  }
@include template('head');
@include template('forum/forum_postsc');
@include template('foot');
?>